fileExists($path . '/' . self::ARTISAN)) { return new EmptyMatchResult(); } return new MatchResult($path, $this->detectVersion($path, $fs)); } private function detectVersion(string $path, Filesystem $fs): ?string { $result = null; $versionFile = $path . '/' . self::VERSION_FILE; if ($fs->fileExists($versionFile)) { preg_match("/VERSION\\s*=\\s*'([^']+)'/", $fs->read($versionFile), $matches); if ($matches !== []) { $result = $matches[1]; } } else { $composerJsonFile = $path . '/' . self::COMPOSER_JSON; if ($fs->fileExists($composerJsonFile)) { try { $json = json_decode($fs->read($composerJsonFile), true, 512, JSON_THROW_ON_ERROR); if ($laravelPackage = $json['require']['laravel/framework'] ?? null) { $result = str_replace('^', '', $laravelPackage); } } catch (JsonException) { // ignore composer.json errors } } } return $result; } }